﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Maticsoft.Web
{
    public partial class NewsDetail : System.Web.UI.Page
    {
        int cid;
        int id;
        protected void Page_Load(object sender, EventArgs e)
        {
            int.TryParse(Request.QueryString["cid"], out cid);
            int.TryParse(Request.QueryString["id"], out id);
            if (!IsPostBack)
            {
                GetData();
                GetNav(cid);
            }
        }

        protected void GetData()
        {
            if (cid > 0)
            {
                BLL.News newsBLL = new BLL.News();
                Model.News newsModel = newsBLL.GetModel(id);
                ltlDetail.Text = newsModel.Detail;
                ltlTitle.Text = newsModel.Title;
                Title = newsModel.Title;
            }
        }

        protected string nav = string.Empty;
        protected string GetNav(int id)
        {
            string curr = string.Empty;
            BLL.Channel catBLL = new BLL.Channel();
            Model.Channel catModel = catBLL.GetModel(id);
            curr = "<span> > </span><a href=\"javascript:;\" class=\"fs-14\">" + catModel.ChannelName + " </a>";
            if (catModel.ParentId != 0)
            {
                nav = GetNav((int)catModel.ParentId) + curr;
            }
            else
            {
                nav = nav + curr;
            }

            return nav;
        }
    }
}